<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>电影信息查询</title>
  </head>
  <body>
	<form action="" method="get"> 
		分类: <select name="cid">
				<option value="0">所有分类</option>
			<c:forEach var="c" items="${categories}">
				<c:if test="${c.id==param.cid}">
				<option value="${c.id}" selected="selected">${c.name}</option>
				</c:if>
				<c:if test="${c.id!=param.cid}">
				<option value="${c.id}">${c.name}</option>
				</c:if>
			</c:forEach>
			</select>
		标题: <input type="text" name="title" value="${title}"/>
		<input type="submit"/>
		<a href="admin/edit">添加新电影</a>
	</form>
	<hr/>
	<table border="1">
		<tr><th>ID</th><th>电影名称</th><th>电影编号</th><th>分类</th><th>导演</th><th>上映时间</th><th>编辑</th><th>海报</th><th>详情</th></tr>
		<c:forEach var="m" items="${movies}">
		<tr><td>${m.id}</td>
			<td>${m.title}</td>
			<td>${m.movieCode}</td>
			<td>${m.category}</td>
			<td>${m.director}</td>
			<td><fmt:formatDate pattern="yyyy-MM-dd" value="${m.dateReleased}"/></td>
			<td><a href="admin/edit?id=${m.id}">编辑</a></td>
			<td><a href="admin/downLoad?fileName=${m.movieCode}.jpg"><img src="images/${m.movieCode}.jpg" style="width: 60px;height: 60px"></a></td>
			<td><a href ="detail?id=${m.id}">详细</a></td>
		</tr>
		</c:forEach>
	</table>
	<hr/>
	<c:if test="${totalPages>0}">
		<c:if test="${page>1}">
			<a href="?page=${page-1}&cid=${param.cid}&title=${param.title}">[上一页]</a>
		</c:if>
		<c:if test="${page<=1}">
			<a>[上一页]</a>
		</c:if>
		<c:if test="${page<totalPages}">
			<a href="?page=${page+1}&cid=${param.cid}&title=${param.title}">[下一页]</a>
		</c:if>
		<c:if test="${page>=totalPages}">
			<a>[下一页]</a>
		</c:if>
		第 ${page} 页，共 ${totalPages} 页
	</c:if>
  </body>
</html>
